//
//  XMLAppointmentDetail.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/4/12.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XMLAppointmentDetail.h"
#import "XXTool.h"
#import "LiuyanDetailModel.h"

@implementation XMLAppointmentDetail

+(void)requestAppointmentDetailWithOrderId:(NSString *)orderID completion:(void (^)(BOOL, XMLAppointmentDetail *))block
{
    [DKHTTPRequest sendDataWithShortUrl:@"msg_yydetail"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&orderid=%@",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,orderID]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 if ([[serverDic objectForKey:@"code"] intValue]==200)
                                 {
                                     block(YES,[XMLAppointmentDetail modelWithDictionary:serverDic]);
                                 }
                                 else
                                 {
                                     block(NO,nil);
                                 }
                                 return YES;
                             } IsBuffering:YES
                      IsNeedReplaceWrap:YES
                        IsUseUpLoadHead:NO];
}

+(void)requestExhiLiuyanDetailWithAppointmentId:(NSInteger)count ID:(NSString *)apID completion:(void (^)(BOOL, XMLAppointmentDetail * data,NSMutableArray <LiuyanDetailModel*> *dataList))block{
    [DKHTTPRequest sendNewDataWithShortUrl:@"zs_mess_detail_2017_"
                                     Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&orderid=%@&nstart=%ld&ntotal=10",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,apID,count]]
                                ImageArray:nil
                                   TimeOut:10
                                Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                    if ([[serverDic objectForKey:@"code"] intValue]==200)
                                    {
                                        NSMutableArray *dataList = [[NSMutableArray alloc] init];
                                        NSArray *list = [serverDic objectForKey:@"detail_list"];
                                        for (int i=0; i<list.count; i++)
                                        {
                                            LiuyanDetailModel *temp = [LiuyanDetailModel modelWithDictionary:list[i]];
                                            [dataList addObject:temp];
                                        }
                                        block(YES,[XMLAppointmentDetail modelWithDictionary:serverDic],dataList);
                                    }
                                    else
                                    {
                                        block(NO,nil,nil);
                                        
                                    }
                                    return YES;
                                } IsBuffering:NO
                         IsNeedReplaceWrap:YES
                           IsUseUpLoadHead:NO];
}


@end
